using System;
using dbvc.context.Assignment;
using dbvc.data;
using dbvc.Queries;
using NUnit.Framework;

namespace tdd.dbvc
{
    public partial class tests
    {
        [Test]
        public void check_assignmets()
        {
            root_login();

            add_users();
            add_projects();

            var users = GenericQuery<db_user>.GetAll();
            var projs = GenericQuery<db_project>.GetAll();

            new CreateAssignment(security.Principal, users[1], projs).Execute();

            Assert.AreEqual(3, GenericQuery<db_user_project>.Count());

            del_assignments();

            new CreateAssignment(security.Principal, users, projs[0]).Execute();

            Assert.AreEqual(4, GenericQuery<db_user_project>.Count());

            del_assignments();

            new CreateAssignment(security.Principal, users, projs).Execute();

            Assert.AreEqual(12, GenericQuery<db_user_project>.Count());

            del_assignments();
            del_users();
            del_projects();
        }

        [Test]
        private void del_assignments()
        {
            GenericQuery<db_user_project>.DeleteAll();

            Assert.AreEqual(0, GenericQuery<db_user_project>.Count());
        }
    }
}